﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing.resizer {
    import org.aswing.*;

    public class ResizerController {

        private static var defaultResizerClass:Class;

        private var _component:Component;
        private var _resizer:Resizer;
        private var _resizable:Boolean;
        private var _resizableDirectly:Boolean;

        public function ResizerController(_arg1:Component, _arg2:Resizer=null){
            if (!_arg1){
                throw (new Error("illegal component when insert to ResizerContainer"));
            };
            this._registerComponent(_arg1, _arg2);
        }
        public static function setDefaultResizerClass(_arg1:Class):void{
            defaultResizerClass = _arg1;
        }
        public static function getDefaultResizerClass():Class{
            return (defaultResizerClass);
        }
        public static function create(_arg1:Component, _arg2:Resizer=null):ResizerController{
            return (new ResizerController(_arg1, _arg2));
        }

        public function getComponent():Component{
            return (this._component);
        }
        public function isResizable():Boolean{
            return (this._resizable);
        }
        public function setResizable(_arg1:Boolean):void{
            if (this._resizable != _arg1){
                this._resizable = _arg1;
                this._resizer.setEnabled(this.isResizable());
            };
        }
        public function getResizer():Resizer{
            return (this._resizer);
        }
        public function setResizer(_arg1:Resizer):void{
            if (_arg1 != this._resizer){
                this._destroyResizer();
                this._resizer = _arg1;
                this._initResizer();
            };
        }
        public function isResizeDirectly():Boolean{
            return (this._resizableDirectly);
        }
        public function setResizeDirectly(_arg1:Boolean):void{
            this._resizableDirectly = _arg1;
            this._resizer.setResizeDirectly(_arg1);
        }
        private function _registerComponent(_arg1:Component, _arg2:Resizer=null):void{
            var _local3:Class;
            this._component = _arg1;
            this._resizable = true;
            this._resizableDirectly = false;
            if (_arg2 == null){
                if (getDefaultResizerClass() == null){
                    setDefaultResizerClass(DefaultResizer);
                };
                _local3 = getDefaultResizerClass();
                _arg2 = new (_local3)();
                if (_arg2 == null){
                    throw (new Error("The defaultResizerClass is set wrong!!"));
                };
            };
            this.setResizer(_arg2);
        }
        private function _initResizer():void{
            this._resizer.setOwner(this.getComponent());
            this._resizer.setEnabled(this.isResizable());
            this._resizer.setResizeDirectly(this.isResizeDirectly());
        }
        private function _destroyResizer():void{
            if (this._resizer != null){
                this._resizer.setOwner(null);
                this._resizer = null;
            };
        }
        public function destroy():void{
            this._destroyResizer();
            this._component = null;
        }

    }
}//package org.aswing.resizer 
